package inet.app.controller.parser;


import inet.app.controller.connect.JsonParser;
import inet.app.model.object.Cau_LG_Item;

import java.util.ArrayList;

import org.json.JSONObject;

import android.util.Log;

public class Parser_Cau_LG {


	private ArrayList<Cau_LG_Item> list = new ArrayList<Cau_LG_Item>();
	private Cau_LG_Item item;
	private String ITEMS = "items";
	private String CODE = "code";
	private String NAME = "name";
	private String DATE = "date";
	private String INFODATE = "infodate";
	private String LOGAN= "logan";
	private String HETGAN = "hetgan";
	private String HOANGDAO = "hoangdao";
	
	public Parser_Cau_LG () {
		
	}
	public ArrayList<Cau_LG_Item> getList(String url) {
		list = new ArrayList<Cau_LG_Item>();
		JSONObject jobject,object,job_items;
		JsonParser jParser = new JsonParser();
		jobject = jParser.getJSONFromUrl(url);
		String code,name,date,infodate,logan,hetgan,hoangdao;
		try {
				String items = jobject.getString(ITEMS);
				job_items = new JSONObject(items);
				code= job_items.getString(CODE);
				name= job_items.getString(NAME);
				date= job_items.getString(DATE);
				infodate= job_items.getString(INFODATE);
				logan= job_items.getString(LOGAN);
				hetgan= job_items.getString(HETGAN);
				hoangdao= job_items.getString(HOANGDAO);
				
				item = new Cau_LG_Item(code, name, date, infodate, logan, hetgan, hoangdao);
				list.add(item);
				
			return list;
        } catch (Exception e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            return null;
        }
		
	}


}
